<!DOCTYPE html>



<html>



<head>



	<title>店铺列表</title>



	<include file='public/head'>



	<style>



		.layui-legend-size{font-size:14px !important;}



		.layui-nopadding{padding:0 !important;}



		.layui-overflow{overflow:auto;}



		.layui-nomargin{margin: 0 !important;}



		.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}



		.layui-input{height:30px !important; }



		.layui-form-search-item .layui-inline{margin-bottom: 5px;} 



		.layui-form-search-item label{margin-left: 15px;}



		.layui-table-page {padding: 7px 0px 0px;}



		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}



	</style>		



</head>



<body>



<!-- layui-tab开始 -->



<div class="layui-tab " lay-filter="demo-tab">



	<!-- 顶部导航菜单开始 -->



	<div class="layui-tab-nav" >



        <ul class="layui-tab-title">



			{:getNav('store','admin_index/index')};



		</ul>



	</div>



	<!-- 顶部导航菜单结束 -->



	<!-- 搜索栏开始 -->



	<fieldset class="layui-elem-field layui-field-title layui-field-padding">



		<legend class="layui-legend-size">搜索</legend>



		<form class="layui-form table-bar" action="{:cmf_plugin_url('Store://admin_index/index')}" lay-filter="form-bar" method="post">



			<div class="layui-form-search-item">



				{$searchStr}



				<button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>



			</div>



		</form>



	</fieldset>







	<div class="layui-card">
		<!-- 表格内容开始 -->
		<div class="layui-card">
			<div class="layui-card-header layui-bg-gray layui-bottom">
				<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger forbiddenAll-btn" ><i class="layui-icon">&#x1006;</i>批量禁用</a>
				<a href="javascript:;" class="layui-btn layui-btn-xs revoerAll-btn" ><i class="layui-icon">&#xe654;</i>批量启用</a>
			</div>
			<div class="layui-card-body layui-nopadding " >
				<table  class="layui-table layui-nomargin" >
					<!-- 表格头 -->
					<thead>
						<tr>
							<th width='20px'>
								<input type='checkbox' id='check-box-all' class='layui-form-checkbox'>
							</th>
							<php>
								//输出表格头
								echo $table->getHeader();
							</php>
							<th style="text-align: center;"><b>操作</b></th>
						</tr>
					</thead>
					<!-- 表格头 -->
					<!-- 表格内容输出 -->
					<form id="f">
					<volist name="list" id="vo">
						<tr>
							<th>
								<input type="checkbox" class='check-box' name='id[]' value='{$vo.store_id}'>
							</th>
							<php>
								echo $table->createHtml($vo);
							</php>
									<td width="120px">
							<php>
								if(!empty($vo['store_id'])){
							</php>			
										<button type='button' class='layui-btn layui-btn-xs layui-btn-primary update-btn' style='font-weight:800 ;' onclick="editStore('{$vo.store_id|default=''}')" data-id='{$vo.store_id|default=''}' title='编辑'><i class='layui-icon'>&#xe642;</i></button>
										<if condition="$vo.store_status == 4"> 	
										<button type='button' class='layui-btn layui-btn-xs layui-btn-primary revoer-btn' style='font-weight:800 ;' data-id='{$vo.store_id|default=''}' title='启用'><i class='layui-icon'>&#xe654;</i></button>
										</if>
										<if condition="$vo.store_status == 2"> 	
										<button type='button' class='layui-btn layui-btn-xs layui-btn-primary forbidden-btn' style='font-weight:800 ;' data-id='{$vo.store_id|default=''}' title='禁用'><i class='layui-icon'>&#x1006;</i></button>
										</if>
										<button type='button' class='layui-btn layui-btn-xs layui-btn-primary detail-btn' style='font-weight:800 ;' data-id='{$vo.store_id|default=''}' title='查看'><i class='layui-icon'>&#xe602;</i></button>
							<php>
								}
							</php>
										</td>
						</tr>
					</volist>
					</form>


					<!-- 表格内容输出结束 -->



				</table>



			</div>



		</div>



		<!-- 表格内容结束 -->



	</div>	







</div>











	<include file='public/scripts'>



<script type="text/javascript">



	//全选/取消
	$('#check-box-all').on('click',function(){
		$('.check-box').prop('checked',$('#check-box-all').prop('checked'));
	});



	//详情
	$('.detail-btn').on('click',function(){
		let id = $(this).data('id');
		let url = "{:cmf_plugin_url('Store://admin_index/storeInfo')}?noNav=1&store_id="+id;
		layer.open({
			type:2
			,title:"详情"
			,closeBtn:false
			,area:['100%','100%']
			,shade:0.8
			,id:'LAY_article'
			,btn:['确定']
			,btnAlign:'c'
			,content:url
			,moveType:1
		});
	})







	function editStore(id){



		//编辑店铺



		let url = "{:cmf_plugin_url('Store://admin_index/editStore')}?id="+id;



		layer.open({



			type: 2//基本层类型  0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）



			,title: '编辑属性'//层的标题



			,shadeClose: true//是否点击遮罩关闭



			,shade: 0.8//遮罩



			,area: ['100%', '100%']//宽高



			,btn:['提交','关闭']//弹框按钮



			,fixed:false//固定



			,content: url //iframe的url



			,yes:function(index, layero){



	        //子页面的请求操作都放子页面



	            var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：



	            iframeWin.tijiao();



			}



			,btn2:function(index, layero){







			}







		});



	}	

    //恢复店铺
    $('.revoer-btn').on('click',function(){
        let id = $(this).data('id');
        //询问
        layer.confirm('确定恢复该店铺吗？',{icon:3,title:'提示',btn:['通过','取消']}
        ,function(index,layero){
            $.ajax({
                url:"{:cmf_plugin_url('Store://admin_index/revoer')}",
                type:'post',
                data:{id:id},
                success:function(data){
                    if (data.code == 1) {
                        layer.msg(data.msg,{icon:1,time:1500},function(){
                            // parent.layer.closeAll();
                            // parent.location.reload(); 
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg,{icon:2,time:1500});
                    }
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
    })

    //批量恢复
    $('.revoerAll-btn').on('click',function(){
        var id = $('#f').serialize();
        //询问
        layer.confirm('确定恢复选中店铺吗？',{icon:3,title:'提示',btn:['通过','取消']}
        ,function(index,layero){
            console.log(id);
            $.ajax({
                url:"{:cmf_plugin_url('Store://admin_index/revoer')}",
                type:'post',
                data:id,
                success:function(data){
                    if (data.code == 1) {
                        layer.msg(data.msg,{icon:1,time:1500},function(){
                            // parent.layer.closeAwindow.reload();ll();
                            // parent.location.reload(); 
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg,{icon:2,time:1500});
                    }
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
    })

    //禁用店铺
    $('.forbidden-btn').on('click',function(){
        let id = $(this).data('id');
        layer.prompt({
            formType: 2,
            value: '',
            title: '禁用原因',
            area: ['500px', '400px'] //自定义文本域宽高
            }, function(value, index, elem){
                $.ajax({
                    url:"{:cmf_plugin_url('Store://admin_index/forbidden')}",
                    type:'post',
                    data:{id:id,reason:value},
                    success:function(data){
                        if (data.code == 1) {
                            layer.msg(data.msg,{icon:1,time:1500},function(){
                                // parent.layer.closeAll();
                                // parent.location.reload(); 
                                location.reload();
                            });
                        } else {
                            layer.msg(data.msg,{icon:2,time:1500});
                        }
                    },
                    error:function(data){
                        console.log(data);
                        layer.msg('系统错误',{time:1200,icon:5});
                    }
                }) 
            layer.close(index);
            });
    });

    //批量禁用
    $('.forbiddenAll-btn').on('click',function(){
        var id = $('#f').serialize();
        layer.prompt({
            formType: 2,
            value: '',
            title: '禁用原因',
            area: ['500px', '400px'] //自定义文本域宽高
            }, function(value, index, elem){
                id['reason'] = value;
                $.ajax({
                    url:"{:cmf_plugin_url('Store://admin_index/forbidden')}?reason="+value,
                    type:'post',
                    data:id,
                    success:function(data){
                        if (data.code == 1) {
                            layer.msg(data.msg,{icon:1,time:1500},function(){
                                // parent.layer.closeAll();
                                // parent.location.reload();
                                location.reload(); 
                            });
                        } else {
                            layer.msg(data.msg,{icon:2,time:1500});
                        }
                    },
                    error:function(data){
                        console.log(data);
                        layer.msg('系统错误',{time:1200,icon:5});
                    }
                }) 
            layer.close(index);
            });
    });    





</script>



</body>



</html>	